<script>
var typeArr = <?php echo  Zend_Json::encode($this->typeArr)?>;
$(document).ready(function(){
    $("#student-table tbody tr:even").addClass('even');
        $("#student-table tbody tr:odd").addClass('odd');
        $("#student-table tbody tr").mouseover(function() {
            $(this).addClass("trover");}).mouseout(function() {
                $(this).removeClass("trover");});
   $("#saveStudentKindForm").ajaxForm(
		   {
			   'success': function(data){
			   jAlert('<?php echo  $this->translate("save completed")?>');
			   }
		   }
    );


   $(".typeBtn").click(function(){
	    var id = $(this).attr('id').substr(5);
	    var s = '<select class="select-type" id="select-'+id+'">';
	    s += '<option value=""></option><option value="0"><?php echo $this->translate("normal group")?></option>';
	    $.each(typeArr,function(i,v){
	    	s += '<option value="'+i+'">'+v+'</option>';
		 });
		s += '</select>';
	    $(this).parent().append(s);
	    $(this).hide();
	});

   $(".student_type_td select").live('change',function(){
	    var id = $(this).val();
	    var sn = $(this).attr('id').substr(7);
	    $("input[name='student_type["+sn+"]']").attr('value',id);

	});


	$("#saveBtn").click(function(){
	    $("#saveStudentKindForm").submit();
	});
});
</script>
<form action="save-student-kind" method="post" id="saveStudentKindForm">
<input type="hidden" name="semester_sn" value="<?php echo  $this->semesterSn?>" />
<table id="student-table" >
<thead>
<tr>
<td colspan="8" style="background:#fdf; border:1px #ff5 solid; padding:5px">

<input type="button" id="saveBtn" value="<?php echo  $this->translate('save')?>" />
<input type="reset" id="resetBtn" value="<?php echo  $this->translate('reset')?>" />
</td>
</tr>
<tr>
<th> NO</th>
<th><?php echo $this->translate('student id')?></th>
<th><?php echo $this->translate('class name')?></th>
<th><?php echo $this->translate('number')?></th>
<th><?php echo $this->translate('stundet sex')?></th>
<th><?php echo $this->translate('student name')?></th>
<th><?php echo $this->translate('student setup')?></th>
<th><?php echo $this->translate('group setup')?></th>
</tr>
</thead>
<tbody>
<?php $i = 0 ;?>
<?php foreach($this->data as $val):?>
<tr>
<td><?php echo  ++$i;?></td>
<td><?php echo $val['student_id']?></td>
<td><?php echo $val['class_name']?></td>
<td><?php echo $val['number']?></td>
<td><?php if ($val['student_sex'] == 'M'):?><span class="boy"><?php echo $this->translate('boy')?></span>
<?php elseif ($val['student_sex']=='F'):?><span class="girl"><?php echo $this->translate('girl')?></span>
<?php endif?></td>
<td><?php echo $val['student_name']?></td>
<td>
<?php foreach ($this->joinArr as $tId=>$tVal):?>
<input type="radio"  id="is_join-<?php echo $val['sn']?>-<?php echo $tId?>" <?php if ($val['is_join']==$tId)Sfs_Html::printChecked(1)?>
 name="is_join[<?php echo $val['sn']?>]"  value="<?php echo $tId?>"  />
<label for="is_join-<?php echo $val['sn']?>-<?php echo $tId?>"><?php echo $this->translate($tVal)?></label>
<?php endforeach?>
</td>
<td class="student_type_td">
<?php if ($val['student_type']):?>
<input type="button"  class="typeBtn select-type" id="type_<?php echo $val['sn']?>" value="<?php echo $this->typeArr[$val['student_type']]?>" />
<?php else:?>
<input type="button"  class="typeBtn"  id="type_<?php echo $val['sn']?>" value="<?php echo  $this->translate('normal group')?>" />
<?php endif?>
<input type="hidden"  name="student_type[<?php echo $val['sn']?>]" value="<?php echo  $val['student_type']?>" />
</td>
</tr>
<?php endforeach?>
</tbody>
</table>
</form>
